import AsyncStorage from "@react-native-async-storage/async-storage"
import { NetWorkService } from "../../apiNetworkServices"

export type RoomState = {
  locationId: string
  body: {
    start_time: string
    end_time: string
    selected_dates: string[]
    provider: string
  }
}

/**
 * Network request used to fetch ethera locations
 * @returns the response ethera locations
 */

const getEtheraProvider = async () => {
  const email = await AsyncStorage.getItem("email")
  const encodedEmail = encodeURIComponent(email);
  return new Promise((resolve, reject) => {
    NetWorkService.Get({
      url: `/api/provider-me?email=${encodedEmail}`,
    })
      .then((res) => {
        resolve(res)
      })
      .catch((error) => reject(error))
  })
}

export { getEtheraProvider }
